From ccdc3ee40654b44989e60d8e728aa2096f539673 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 27 Jan 2020 02:49:36 +0100 Subject: [PATCH] selector: Make :not() selectors not radical :not() selectors cannot be radical because the bloomfilter only knows if a value is set in any of the nodes, but cannot determine the opposite (if a value is not set in at least one node), but that would be required for:not() selectors. However, this is very unlikely to happen in the real world, so it's not worth optimizing. Unfortunately, change tracking could know this, so by excluding the :not() selectors from radical changes, the change tracking will now pick them up. If that turns out to be a performance problem, we need to add a special category for radical not filters, so change tracking and bloom filters can deal with them. The testcase demonstrating the problem in widget-factory has been extrated and added. --- gtk/gtkcssselector.c | 2 +- testsuite/css/change/test4.nodes | 2 +- testsuite/css/style/bloomfilter-not.css | 1 + testsuite/css/style/bloomfilter-not.nodes | 20 +++++++++++ testsuite/css/style/bloomfilter-not.ui | 43 +++++++++++++++++++++++ testsuite/css/style/meson.build | 3 ++ 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 testsuite/css/style/bloomfilter-not.css create mode 100644 testsuite/css/style/bloomfilter-not.nodes create mode 100644 testsuite/css/style/bloomfilter-not.ui diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index bd1edb1240..8f4bbf0113 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -540,7 +540,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ ## c = { \ \ static const GtkCssSelectorClass GTK_CSS_SELECTOR_NOT_ ## c = { \ "not_" G_STRINGIFY(n), \ - ignore_for_change ? GTK_CSS_SELECTOR_CATEGORY_SIMPLE : GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL, \ + GTK_CSS_SELECTOR_CATEGORY_SIMPLE, \ gtk_css_selector_not_ ## n ## _print, \ gtk_css_selector_default_foreach_matcher, \ gtk_css_selector_not_ ## n ## _match_one, \ diff --git a/testsuite/css/change/test4.nodes b/testsuite/css/change/test4.nodes index 2919416d1a..79cf087303 100644 --- a/testsuite/css/change/test4.nodes +++ b/testsuite/css/change/test4.nodes @@ -5,4 +5,4 @@ window.background:dir(ltr) label.b:dir(ltr) class|name|hover|backdrop label.c:dir(ltr) class|name|parent-name|parent-hover label.d:dir(ltr) class|name|parent-name|parent-hover|parent-backdrop - label.e.f:dir(ltr) + label.e.f:dir(ltr) class|name|parent-name|parent-hover|parent-backdrop diff --git a/testsuite/css/style/bloomfilter-not.css b/testsuite/css/style/bloomfilter-not.css new file mode 100644 index 0000000000..8ffa7138ff --- /dev/null +++ b/testsuite/css/style/bloomfilter-not.css @@ -0,0 +1 @@ +.linked:not(.vertical) > button:dir(ltr):not(:last-child) { color: pink; } diff --git a/testsuite/css/style/bloomfilter-not.nodes b/testsuite/css/style/bloomfilter-not.nodes new file mode 100644 index 0000000000..ac98aa82c0 --- /dev/null +++ b/testsuite/css/style/bloomfilter-not.nodes @@ -0,0 +1,20 @@ +window.background.solid-csd:dir(ltr) + decoration:dir(ltr) + headerbar.titlebar:dir(ltr) + box.horizontal.start:dir(ltr) + stackswitcher.linked:dir(ltr) + button.text-button.toggle:dir(ltr):checked + color: rgb(255,192,203); /* bloomfilter-not.css:1:61-73 */ + + label:dir(ltr) + button.text-button.toggle:dir(ltr) + color: rgb(255,192,203); /* bloomfilter-not.css:1:61-73 */ + + label:dir(ltr) + button.text-button.toggle:dir(ltr) + label:dir(ltr) + box.end.horizontal:dir(ltr) + stack:dir(ltr) + box.horizontal:dir(ltr) + box.horizontal:dir(ltr) + box.horizontal:dir(ltr) diff --git a/testsuite/css/style/bloomfilter-not.ui b/testsuite/css/style/bloomfilter-not.ui new file mode 100644 index 0000000000..cdbbfeb0ba --- /dev/null +++ b/testsuite/css/style/bloomfilter-not.ui @@ -0,0 +1,43 @@ + + + + + + + + toplevel_stack + + + + + + + 1000 + + + Page 1 + + + + + + + + Page 2 + + + + + + + + Page 3 + + + + + + + + + diff --git a/testsuite/css/style/meson.build b/testsuite/css/style/meson.build index fa2515f313..3198b85c05 100644 --- a/testsuite/css/style/meson.build +++ b/testsuite/css/style/meson.build @@ -30,6 +30,9 @@ test_data = [ 'adjacent-states.css', 'adjacent-states.nodes', 'adjacent-states.ui', + 'bloomfilter-not.css', + 'bloomfilter-not.nodes', + 'bloomfilter-not.ui', 'colornames.css', 'colornames.nodes', 'colornames.ui', -- 2.30.2